package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.ShoppingCart;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 动态查询购物车数据
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 购物车商品数量+1
     * @param cart
     */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updata(ShoppingCart cart);

    /**
     * 将商品添加至购物车
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void cleanSC(Long userId);

    /**
     * 删除购物车中数量为1商品
     */
    @Delete("delete from shopping_cart where id = #{id}")
    void delete(Long id);

    /***
     * 批量添加购物车
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);

    /**
     * 查询用户购物车内容
     * @param userId
     * @return
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> selectById(Long userId);
}
